var app = angular.module('userApp', []);

app.controller('userController', function($scope, $http) {
	$scope.pwd;
	$scope.view=function(){
		$http.get(timestamp("sys/users/get/"+getQueryString("id"))).success(function (response) {
			$scope.user = response.data;
			$scope.pwd = $scope.user.password;
		});
	}
	
	$scope.view();
	$scope.refreshData=function(){
		$scope.view();
	}
	
	$scope.userSave=function(){
	   if($("#myForm").valid()){
		   if($scope.user.password==$scope.pwd){
			   $scope.user.password=null;
		   }
		   $http.put('sys/users/modify/', $scope.user).success(function(){
			   redirectUrl("manage/user/","list.jsp");
           });
	   }
	}
	
	$scope.userReset=function(){
		$scope.view();
	}
	
	$scope.userCancle=function(){
		  redirectUrl("manage/user/","list.jsp");
	}
});